<?php
    drupal_add_css('css/style.dev1.css');
    drupal_add_css('css/ui-lightness/jquery-ui-1.8.16.custom.css');
    drupal_add_js('js/jquery-ui-1.8.16.custom.min.js');
    drupal_add_js('js/jquery.validate.min.js');
    drupal_add_js('misc/collapse.js');
    drupal_add_js('js/script.user.js');    
?>
<form <?php echo empty($data) ? 'name="add_user" id="add_user"' : 'name="edit_user" id="edit_user"'; ?> action="" method="POST" enctype="multipart/form-data">
    <fieldset class="menu-item-form collapsible">
        <legend class="menu-item-form collapsible"><a style="cursor: pointer">Thông tin đăng nhập</a></legend>    
        <div>
            <div class="node-form">
                <div class="standard">
                    <div id="content-inner">
                        <div class="form-item">
                            <label for="name">Tên đăng nhập: <span title="Trường bắt buộc." class="form-required">*</span></label>
                            <input type="text" <?php if(!empty($data['u'])) echo 'value="' . $data['u']->name . '" readonly="readonly"' ?> size=50" id="name" name="name" maxlength="60" />
                        </div>
                        <div class="form-item">
                            <label for="mail">Email: <span title="Trường bắt buộc." class="form-required">*</span></label>
                            <input type="text" <?php if(!empty($data['u'])) echo 'value="' . $data['u']->mail . '" readonly="readonly"' ?> size=50" id="mail" name="mail" maxlength="64" />
                        </div>
                        <div class="form-item">
                            <label for="pass">Mật khẩu: <span title="Trường bắt buộc." class="form-required">*</span></label>
                            <input type="password" value="" size=50" id="pass" name="pass" />
                        </div>
                        <div class="form-item">
                            <label for="re_pass">Xác nhận mật khẩu: <span title="Trường bắt buộc." class="form-required">*</span></label>
                            <input type="password" value="" size=50" id="re_pass" name="re_pass" />
                        </div>
                        <div class="form-item">
                            <label for="status">Trạng thái:</label>
                            <label class="label-in-line" for="status_1"><input value="1" type="radio" name="status" id="status_1" checked="checked" /> Hoạt động</label>
                            <label class="label-in-line" for="status_0"><input value="0" type="radio" name="status" id="status_0" <?php if(!empty($data['u']) && $data['u']->status == USER_STATUS_BLOCKED) echo 'checked="checked"' ?> /> Ngưng Hoạt động</label>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
    
    <input type="submit" value="Lưu" />                
    <input type="reset" <?php echo empty($data) ? 'rel="add_user"' : 'rel="edit_user"'; ?> value="Nhập lại" />                
    <?php echo l('Quay lại', 'back-end/usermanager') ?>
    <fieldset class="menu-item-form collapsible collapsed">
        <legend class="menu-item-form collapsible"><a style="cursor: pointer">Thông tin chi tiết</a></legend>    
        <div>
            <div class="node-form">
                <div class="standard">
                    <div id="content-inner">
                        <div class="form-item">
                            <label for="first_name">Tên đệm:</label>
                            <input type="text" value="<?php if(!empty($data['ud'])) echo $data['ud']->first_name ?>" size=50" id="first_name" name="data[first_name]" maxlength="50" />
                        </div>
                        <div class="form-item">
                            <label for="last_name">Tên:</label>
                            <input type="text" value="<?php if(!empty($data['ud'])) echo $data['ud']->last_name ?>" size=50" id="last_name" name="data[last_name]" maxlength="50" />
                        </div>
                        <div class="form-item">
                            <label for="gender">Giới tính:</label>
                            <label class="label-in-line" for="gender_male"><input value="Nam" type="radio" name="data[gender]" id="gender_male" checked="checked" /> Nam</label>
                            <label class="label-in-line" for="gender_female"><input value="Nữ" type="radio" name="data[gender]" id="gender_female" <?php if(!empty($data['ud']) && $data['ud']->gender == 'Nữ') echo 'checked="checked"' ?> /> Nữ</label>
                        </div>
                        <div class="form-item">
                            <label for="birthday">Ngày sinh:</label>                            
                            <input type="text" value="<?php if(!empty($data['ud'])) echo date('m/d/Y', $data['ud']->birthday) ?>" size=50" id="birthday" name="data[birthday]" maxlength="20" readonly="readonly" style="width: 120px" />
                        </div>
                        <div class="form-item">
                            <label for="address">Địa chỉ:</label>
                            <textarea id="address" name="data[address]" style="width: 400px; height: 80px;"><?php if(!empty($data['ud'])) echo $data['ud']->address ?></textarea>
                        </div>
                        <div class="form-item">
                            <label for="telefone">Điện thoại:</label>
                            <input type="text" value="<?php if(!empty($data['ud'])) echo $data['ud']->telefone ?>" size=50" id="telefone" name="data[telefone]" maxlength="30" />
                        </div>
                        <div class="form-item">
                            <label for="fax">Điện thoại:</label>
                            <input type="text" value="<?php if(!empty($data['ud'])) echo $data['ud']->fax ?>" size=50" id="fax" name="data[fax]" maxlength="20" />
                        </div>
                        <div class="form-item">
                            <label for="mobile">Di động:</label>
                            <input type="text" value="<?php if(!empty($data['ud'])) echo $data['ud']->mobile ?>" size=50" id="mobile" name="data[mobile]" maxlength="30" />
                        </div>
                        <div class="form-item">
                            <label for="description">Mô tả:</label>
                            <textarea id="description" name="data[description]" style="width: 400px; height: 80px;"><?php if(!empty($data['ud'])) echo $data['ud']->description ?></textarea>
                        </div>
                        <div class="form-item">
                            <label for="avatar">Hình đại diện:</label>                            
                            <input type="file" name="avatar" id="avatar" value="" />
                            <?php
                                if (!empty($data['ud'])) {
                                    $avatar = $data['ud']->avatar != null ? $data['ud']->avatar : 'no_avatar.gif';
                                    $img = '<br /><img width="85" src="' . USER_AVATAR . '/' . $avatar . '" alt="' . $data['ud']->name . '" title="Hình đại diện của thành viên: ' . $data['ud']->name . '" />';
                                    echo $img;
                                }
                            ?>
                        </div>
                        <div class="form-item">
                            <label for="company">Công ty:</label>
                            <input type="text" value="<?php if(!empty($data['ud'])) echo $data['ud']->company ?>" size=50" id="company" name="data[company]" maxlength="100" />
                        </div>
                        <div class="form-item">
                            <label for="location_index">Tỉnh/Thành:</label>
                            <select id="location_index" name="data[location_index]">
                                <option value="">Chọn tỉnh thành</option>
                                <?php
                                    if (!empty($data['listLocal'])) {
                                        foreach ($data['listLocal'] as $local) {
                                            echo '<option ' . ($data['ud']->location_index == $local->indexs ? 'selected="selected"':'') . ' value="' . $local->indexs . '">' . $local->name . '</option>';
                                        }
                                    }
                                ?>
                            </select>
                            <input type="hidden" id="location" name="data[location]" />
                        </div>
                        <div class="form-item">
                            <label for="website">Website:</label>
                            <input type="text" value="<?php if(!empty($data['ud'])) echo $data['ud']->website ?>" size=50" id="website" name="data[website]" maxlength="100" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </fieldset>

</form>